package LeetCode.month02.day54;

public class No129 {
    int res = 0;
    public int sumNumbers(TreeNode root) {
        getSum(root,0);
        return res;
    }

    public void getSum(TreeNode root, int sum){
        if(root==null) return;
        sum = sum*10+root.val;
        if(root.left==null&&root.right==null){
            res+=sum;
        }
        getSum(root.left,sum);
        getSum(root.right,sum);
    }
}
